﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace HTComics.Data.Tools
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

        private void MainForm_Load(object sender, EventArgs e)
        {
            //string connString = "Data Source=173.0.135.245;Initial Catalog=JKComics_DB;User Id=JKComics_DBA;Password=7Nation!;";
            string connString = "Data Source=localhost;Initial Catalog=HTCDB;User Id=sa;Password=7Nation!;";

            DataResetter resetter = new DataResetter(connString);
            DataInserter inserter = new DataInserter(connString);
            DataFormatter formatter = new DataFormatter(connString);

            //RESET DB
            string error;

            //error = resetter.EmptyTables();
            //error = resetter.ReseedTableIdentities();
            //error = resetter.InsertBasicData();

            //INSERT
            List<string> errors;
            string qs;
            DataTable dtData = DataImporter.ImportData(connString, System.IO.Path.GetDirectoryName(Application.ExecutablePath) + @"\..\..\Data\[23-04-2012]5944 lines a-n.txt", out errors);
            inserter.InsertData(dtData, out qs);
            
            //gvPreview.DataSource = dtData;


            //TEST           
            //DataTable dtComicIds = DataTester.GetDuplicateIssues(connString);
            //for (int i = 0; i <= dtComicIds.Rows.Count - 1; i++)
            //{
            //    DataTable dtDupIssues = DataTester.GetActualDuplicateIssues(connString, dtComicIds.Rows[i]["ComicId"].ToString(), dtComicIds.Rows[i]["IssueNumber"].ToString(), dtComicIds.Rows[i]["ConditionId"].ToString());
            //    richTextBox1.Text += DataTester.GetSql(dtDupIssues);
           // }

            //DataTable dtNonnumericIssues = formatter.GetNonNumericIssues();
            //formatter.FormatIssueNumbers(dtNonnumericIssues);

        
        }
    }
}
